﻿using System;

namespace AgFractal.Fractals
{
    public class Gopalsamy1: AbstractFractal
    {
        public Gopalsamy1()
        {
            ID = new Guid("59960DE6-A2F8-42da-8D82-847B4AE118A9");
            Name = Description = "Gopalsamy1";
            R1 = -3; I1 = 2; R2 = 3; I2 = -2;
            var cParam = new FractalParameter { Name = "c", ComplexValue = c };
            cParam.PropertyChanged += (s, e) => c = cParam.ComplexValue;
            parameter.Add(cParam);
        }

        Complex c = new Complex(-0.19, -0.19);
        protected override short Calculate(double r, double i, short MaxIteration)
        {
            short j;
            Complex z = new Complex(r, i);            
            for (j = 0; j < MaxIteration; j++)
            {
                z = (z * z).Conj() + c;
                if (z.Abs2() > 100000000) break;
            }
            return j;
        }
    }
}